package com.example.mybatis.business.impl;

import com.example.mybatis.business.IUserBusiness;
import com.example.mybatis.dao.IUserDao;
import com.example.mybatis.form.UserForm;
import com.example.mybatis.model.UserTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


import java.util.List;

@Component
public class UserBusiness implements IUserBusiness {
    @Autowired
    private IUserDao userDao;
    @Override
    public UserTO queryUsersByAccount(String userAccount){
        return userDao.queryUsersByAccount(userAccount);
    }

    @Override
    public void addUserInfo(UserTO userTO) throws Exception {
        userDao.addUserInfo(userTO);
    }

    @Override
    public void updateUserInfo(UserTO userTO) throws Exception {
        userDao.updateUserInfo(userTO);
    }

    @Override
    public void batchInsertUserInfo(List<UserTO> items) throws Exception {
        userDao.batchAddUserInfo(items);
    }

    @Override
    public List<UserTO> selectAllUser(int startIndex,int pageSize) {

        return userDao.selectAllUser(startIndex,pageSize);
    }

    @Override
    public int queryTotalRows(String dbName) {
        return userDao.queryTotalRows(dbName);
    }

    @Override
    public void batchUpdateUserInfo(List<UserTO> items) throws Exception {
        userDao.batchUpdateUserInfo(items);
    }

    @Override
    public void deleteUserInfo(String userAccount) throws Exception {
        userDao.deleteUserInfo(userAccount);
    }

    @Override
    public void batchDeleteUserInfo(List<String> userAccounts) throws Exception {
        userDao.batchDeleteUserInfo(userAccounts);
    }

    @Override
    public List<String> queryExistUserAccounts(List<String> userAccounts){
        return userDao.queryExistUserAccounts(userAccounts);
    }

    @Override
    public List<UserTO> searchUsers(UserForm userForm) throws Exception {
        List<UserTO> users = userDao.searchUsers(userForm);
        return users;
    }
}
